package com.ihr360.cnb.module.payroll.dataFix;

import com.ihr360.cnb.module.payroll.service.PayrollAggregateService;
import com.ihr360.commons.vo.ResultInfo;
import com.ihr360.entity.SyncedRosterSalaryChangeRecordEntity;
import com.ihr360.shared.advice.response.DisableResponseAdvice;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author richey
 */
@RestController
@RequestMapping("/payroll")
@DisableResponseAdvice
public class PayrollDataFixController {


    @Autowired
    private PayrollAggregateService payrollAggregateService;

    /**
     * 薪资上线前初始化公司薪资档案数据
     *
     * @return
     */
    @GetMapping(value = "/companySalaryProfile/batchInit")
    @ApiOperation(value = "/companySalaryProfile/batchInit", httpMethod = "GET", notes = "公司薪资档案数据批量初始化",
            consumes = "application/json;charset=UTF-8", produces = "application/json;charset=UTF-8")
    public ResultInfo batchInitCompanySalaryProfile() {
        return payrollAggregateService.batchInitCompanySalaryProfile();
    }


    /**
     * 薪资上线前同步员工薪资数据，要在薪资档案数据初始化结束后执行
     *
     * @return
     */
    @GetMapping(value = "/staffSalaryProfile/init")
    @ApiOperation(value = "/staffSalaryProfile/init", httpMethod = "GET", notes = "irenshi员工转正相关薪资初始化",
            consumes = "application/json;charset=UTF-8", produces = "application/json;charset=UTF-8")
    public void initStaffSalaryProfile() {
        payrollAggregateService.initIrsProbationData();
    }


    /**
     * 除irs转正数据外其他员工薪资的初始化
     *
     * @return
     */
    @GetMapping(value = "/staffSalaryProfile/init/excludeFromIrs")
    @ApiOperation(value = "/staffSalaryProfile/init/excludeFromIrs", httpMethod = "GET", notes = "除irs转正数据外其他员工薪资的初始化",
            consumes = "application/json;charset=UTF-8", produces = "application/json;charset=UTF-8")
    public ResultInfo initStaffSalaryProfileExcludeFromIrs() {
        return payrollAggregateService.initExcludeFromIrs();
    }


    /**
     * 转正/调岗调薪-->员工薪资
     * 目前通过binlog做
     * @param entity
     * @return
     */
    @PostMapping(value = "/staffsalary/adjust")
    public ResultInfo adjustStaffSalaryProfile(@RequestBody SyncedRosterSalaryChangeRecordEntity entity) {
        return payrollAggregateService.adjustStaffSalaryProfile(entity);
    }

    /**
     * 员工薪资相关修复，纳税身份、银行卡信息，要在员工信息初始化后执行
     * */
    @GetMapping(value = "/staffBankInfo/init")
    @ApiOperation(value = "/staffBankInfo/init", httpMethod = "GET", notes = "员工薪资相关修复，纳税身份、银行卡信息，要在员工信息初始化后执行",
            consumes = "application/json;charset=UTF-8", produces = "application/json;charset=UTF-8")
    public void initStaffBankInfo() {
         payrollAggregateService.initStaffBankInfo();
    }


}
